<?php

/**
 * @author Martin Pernica
 * @copyright 2008
 */

class SeoUrl{

	var $result;

	var $pattern = "SeoPattern.txt";

	public function Parse($url){
		$url = strtr($url, parse_ini_file($this->pattern));
		$url = iconv("utf-8", "us-ascii//TRANSLIT", $url);
		$url = strtolower($url);
		$url = str_replace('-', '', $url);
		$url = str_replace('!', '', $url);
		$url = str_replace('/', '', $url);
		$url = str_replace(' ', '-', $url);
		$url = str_replace('.', '', $url);
		$url = str_replace('?', '', $url);
		$url = str_replace('&', '', $url);
		$url = str_replace(':', '', $url);
		$url = str_replace('(', '', $url);
		$url = str_replace(')', '', $url);
		$url = str_replace('+', 'p', $url);
		$url = str_replace('#', '', $url);
		$url = str_replace('@', '', $url);
		$url = str_replace('"', '', $url);
		$url = str_replace('\'', '', $url);
		$url = str_replace('*', '', $url);
		$url = str_replace('%', '', $url);
		$url = preg_replace("/[^[:alpha:][:digit:]]/", "-", $url);
		$url = preg_replace("/-+/", "-", $url);
		$url = trim($url, "-");
		$url = trim($url, " ");
		//$url = urlencode($url);

		$this->result = $url;
	}

}

?>